<template>
  <div style="padding:20px 15px 40px 15px">
    <el-card shadow="hover">
        <el-form inline>
            <el-form-item label='订单编号:'><el-input placeholder="请输入订单编号" @change="search()" clearable style="width:200px" v-model="queryParams.orderSn"></el-input></el-form-item>
            <el-form-item label="入库日期">
                <el-date-picker
                    clearable
                    v-model="queryParams.startTime"
                    value-format="yyyy-MM-dd"
                    @change="search()"
                    type="date"
                    placeholder="选择日期">
                    </el-date-picker>
                    -
                    <el-date-picker
                    clearable
                    v-model="queryParams.endTime"
                    @change="search()"
                    type="date"                          
                    value-format="yyyy-MM-dd"
                    placeholder="选择日期">
                    </el-date-picker>
            </el-form-item>
            <el-form-item label='入库数量:'><el-input placeholder="请输入入库数量" @change="search()" clearable style="width:200px" v-model="queryParams.putNumber"></el-input></el-form-item>
            <el-form-item label="型号:">
                <!-- <el-input v-model="queryParams.model" @change="search()" style="width:200px" clearable></el-input> -->
                <el-select v-model="queryParams.model" placeholder="请选择型号" @change="search()" style="width:200px" clearable >
                    <el-option
                    v-for="item in modelOptions"
                    :key="item.dictLabel"
                    :label="item.dictLabel"
                    :value="item.dictLabel"
                    >
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="尺寸:">
                <!-- <el-input v-model="queryParams.dimensions" @change="search()" style="width:200px" clearable></el-input> -->
                <el-select v-model="queryParams.dimensions" placeholder="请选择尺寸" @change="search()" style="width:200px" clearable >
                    <el-option
                    v-for="item in sizeOptions"
                    :key="item.dictLabel"
                    :label="item.dictLabel"
                    :value="item.dictLabel"
                    >
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="功率:">
                <el-select v-model="queryParams.wattage" placeholder="请选择功率" @change="search()" style="width:200px" clearable >
                    <el-option
                    v-for="item in watOptions"
                    :key="item.dictLabel"
                    :label="item.dictLabel"
                    :value="item.dictLabel"
                    >
                    </el-option>
                </el-select>
            </el-form-item>
             <!-- <el-form-item label="状态:" prop="status">
                <el-select
                v-model="queryParams.status"
                placeholder="库存状态"
                clearable
                style="width: 200px"
                filterable 
                @change="search()"
                >
                <el-option
                    v-for="dict in statusOptions"
                    :key="dict.dictValue"
                    :label="dict.dictLabel"
                    :value="dict.dictValue"
                />
                el-item
                </el-select>
            </el-form-item> -->
            <el-form-item><el-button v-hasPermi="['stock:add']" @click="add" type="warning" size="mini">新增</el-button></el-form-item>
        </el-form>
    </el-card>
    <!-- <el-row style="margin-top:20px">
        <el-col :span="10"> -->
            <!-- <el-card shadow="hover" style="margin-top:20px">
                <el-form inline>
                    <el-row>
                        <el-col :span="24">
                        <el-form-item label="发货日期">
                            <el-date-picker
                                clearable
                                v-model="params1.startDate"
                                value-format="yyyy-MM-dd"
                                type="date"
                                placeholder="选择日期">
                                </el-date-picker>
                                -
                                <el-date-picker
                                clearable
                                v-model="params1.endDate"
                                @change="search1()"
                                type="date"                          
                                value-format="yyyy-MM-dd"
                                placeholder="选择日期">
                                </el-date-picker>
                        </el-form-item>
                        <el-form-item label-width="50px">
                            单位:兆瓦
                        </el-form-item>
                        </el-col>
                    <el-col :span="5">
                        <el-form-item label="累计发货量:">
                            <span style="font-size:20px;font-weight: 600;">{{deliverCount}}</span>
                        </el-form-item>
                    </el-col>
                    <el-col :span="5">
                        <el-form-item label="总剩余量(未领取):">
                            <span style="font-size:20px;font-weight: 600;">{{surplusCount}}</span>
                        </el-form-item>
                    </el-col>
                    <el-col :span="5">
                        <el-form-item label="未付款量:">
                            <span style="font-size:20px;font-weight: 600;">{{unpaidCount}}</span>
                        </el-form-item>
                    </el-col>
                    <el-col :span="5">
                        <el-form-item label="已预付量:">
                            <span style="font-size:20px;font-weight: 600;">{{advanceCount}}</span>
                        </el-form-item>
                    </el-col>
                    <el-col :span="4">
                        <el-form-item label="总库存量:">
                            <span style="font-size:20px;font-weight: 600;">{{totalCount}}</span>
                        </el-form-item>
                    </el-col>
                    </el-row>
                </el-form>
            </el-card> -->
    
    <el-table 
        v-loading="loading"
        :data="tableData"
        style="margin-top:20px;width: 100%;"
        border
        class="table"
        ref="multipleTable"
        header-cell-class-name="table-header">
        <el-table-column prop="orderSn" align="center" label="订单号" width="120"></el-table-column>
        <el-table-column prop="putTime" width="100" align="center" label="入库日期" ></el-table-column>
        <el-table-column prop="typeName" align="center" label="价格类型" width="100"></el-table-column>
        <el-table-column width="60" prop="unitPrice" align="center" label="单价"></el-table-column>
        <el-table-column prop="assemblyLevel" align="center" label="等级"></el-table-column>
        <el-table-column prop="model" align="center" label="型号" width="120"></el-table-column>
        <el-table-column prop="wattage" align="center" label="功率"></el-table-column>
        <el-table-column width="180" prop="crystal" align="center" label="入库理由" ></el-table-column>
        <el-table-column  prop="putNumber" align="center" label="入库数量"></el-table-column>
        <el-table-column prop="surplusNumber" align="center" label="剩余数量" width="105"></el-table-column>
        <el-table-column prop="receiveNumber" align="center" label="领取数量" width="105"></el-table-column>
        <el-table-column prop="reserveCount" align="center" label="预定占用" width="105"></el-table-column>
        <el-table-column prop="advanceCount" align="center" label="预付占用" width="105"></el-table-column>
        <el-table-column prop="paymentCount" align="center" label="全款占用" width="105"></el-table-column>

        <el-table-column prop="dimensions" align="center" label="尺寸" width="120"></el-table-column>
        <el-table-column prop="borderColor" align="center" label="边框颜色" width="120"></el-table-column>
        <el-table-column prop="lineLength" align="center" label="线长" width="120"></el-table-column>
        <el-table-column prop="backboard" align="center" label="背板" width="120"></el-table-column>
        <el-table-column prop="identification" align="center" label="能源标识" width="120"></el-table-column>
        <el-table-column prop="nameplate" align="center" label="铭牌" width="120"></el-table-column>
        <!-- <el-table-column prop="packing" align="center" label="包装" width="120"></el-table-column> -->
        <el-table-column prop="standards" align="center" label="包装" width="120"></el-table-column>

        <!-- <el-table-column prop="watts" align="center" label="总功率（兆瓦）"></el-table-column> -->
        <el-table-column prop="factory" align="center" label="所在工厂" width="220"></el-table-column>
        <el-table-column prop="totalPrice" align="center" label="总价"></el-table-column>
        
        <el-table-column show-overflow-tooltip prop="content" align="center" label="计划备注" width="220"></el-table-column>
        <el-table-column width="220" align="center" label="操作" fixed="right">
            <template slot-scope="scope">
                <el-button  v-hasPermi="['stock:ed']" @click="ed(scope.row)" type="text">编辑</el-button>
                <el-button v-if="scope.row.surplusNumber != 0" @click="receive(scope.row)" type="text">领取</el-button>
                <el-button  v-hasPermi="['stock:list']" @click="see(scope.row)" type="text">查看领取记录</el-button>
                <!-- <el-button type="text">入库记录</el-button> -->
                <!-- <el-button type="text">删除</el-button> -->
            </template>
        </el-table-column>
        </el-table>
        <pagination
            v-show="total > 0"
            :total="total"
            :page.sync="queryParams.pageNum"
            :limit.sync="queryParams.pageSize"
            @pagination="getList00"
        >
        </pagination>
        <el-dialog :title="title" :visible.sync="open" width="850px">
            <el-form :model="form" :rules="rules" ref="form" label-width="120px">
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="订单号:" prop="orderSn">
                            <el-input v-model="form.orderSn" style="width:220px"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="价格类型:" prop="typeId">
                            <el-select v-model="form.typeId" placeholder="请选择">
                                <el-option v-for="(item , index) in options" :key="index" :label="item.type" :value="item.id"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="入库日期:" prop="putTime">
                            <el-date-picker v-model="form.putTime" value-format="yyyy-MM-dd" type="date" placeholder="选择日期"></el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="入库理由:" prop="crystal">
                            <el-select v-model="form.crystal" placeholder="请选择入库原因" clearable >
                                <el-option
                                v-for="item in crystalOptions"
                                :key="item.dictLabel"
                                :label="item.dictLabel"
                                :value="item.dictLabel"
                                >
                                </el-option>
                            </el-select>
                            <!-- <el-select v-model="form.crystal" placeholder="请选择">
                                <el-option label="单晶" value="单晶"></el-option>
                                <el-option label="多晶" value="多晶"></el-option>
                            </el-select> -->
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="型号:" prop="model">
                            <!-- <el-input v-model="form.model"></el-input> -->
                            <el-select v-model="form.model" placeholder="请选择型号" clearable >
                                <el-option
                                v-for="item in modelOptions"
                                :key="item.dictLabel"
                                :label="item.dictLabel"
                                :value="item.dictLabel"
                                >
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="尺寸:" prop="dimensions">
                            <!-- <el-input v-model="form.dimensions"></el-input> -->
                            <el-select v-model="form.dimensions" placeholder="请选择尺寸" >
                            <el-option
                            v-for="item in sizeOptions"
                            :key="item.dictLabel"
                            :label="item.dictLabel"
                            :value="item.dictLabel"
                            >
                            </el-option>
                        </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="边框颜色:" prop="borderColor">
                            <el-select style="width:205px" v-model="form.borderColor" placeholder="请选择">
                                <el-option label="银色" value="银色"></el-option>
                                <el-option label="黑色" value="黑色"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="线长:" prop="lineLength">
                            <el-select v-model="form.lineLength" placeholder="请选择线长" >
                                <el-option
                                v-for="item in lineOptions"
                                :key="item.dictLabel"
                                :label="item.dictLabel"
                                :value="item.dictLabel"
                                >
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>

                 <el-row>
                    <el-col :span="12">
                        <el-form-item label="背板:" prop="backboard">
                            <el-select v-model="form.backboard" placeholder="请选择背板" >
                                <el-option
                                v-for="item in backboardOptions"
                                :key="item.dictLabel"
                                :label="item.dictLabel"
                                :value="item.dictLabel"
                                >
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="能源标识:" prop="identification">
                            <el-select v-model="form.identification" placeholder="请选择能源标识" >
                                <el-option
                                v-for="item in enerOptions"
                                :key="item.dictLabel"
                                :label="item.dictLabel"
                                :value="item.dictLabel"
                                >
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="功率(瓦):" prop="wattage">
                            <!-- <el-input v-model="form.wattage"></el-input> -->
                            <el-select v-model="form.wattage" placeholder="请选择功率" >
                                <el-option
                                v-for="item in watOptions"
                                :key="item.dictLabel"
                                :label="item.dictLabel"
                                :value="item.dictLabel"
                                >
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="入库数量:" prop="putNumber">
                            <el-input-number :min="1" controls-position="right" v-model="form.putNumber" style="width:208px"></el-input-number>
                        </el-form-item>
                    </el-col>
                </el-row>

                <el-row>
                    <el-col :span="12">
                        <el-form-item label="铭牌:" prop="nameplate">
                            <el-select v-model="form.nameplate" placeholder="请选择铭牌" >
                                <el-option
                                v-for="item in nameplateOptions"
                                :key="item.dictLabel"
                                :label="item.dictLabel"
                                :value="item.dictLabel"
                                >
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                         <el-form-item label="等级:" prop="assemblyLevel">
                            <!-- <el-input v-model="form.assemblyLevel"></el-input> -->
                            <el-select  v-model="form.assemblyLevel" placeholder="请选择">
                                <el-option label="A级" value="A级"></el-option>
                                <el-option label="A-级" value="A-级"></el-option>
                                <el-option label="P级" value="P级"></el-option>
                                <el-option label="C级" value="C级"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>

                <el-row>
                    <el-col :span="12">
                        <el-form-item label="所在工厂:" prop="factory">
                            <!-- <el-input v-model="form.factory"></el-input> -->
                            <el-select v-model="form.factory" placeholder="请选择所在工厂" >
                                <el-option
                                v-for="item in baseOptions"
                                :key="item.dictLabel"
                                :label="item.dictLabel"
                                :value="item.dictLabel"
                                >
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="包装规格:" prop="standards">
                            <el-input v-model="form.standards" style="width:220px"></el-input>
                        </el-form-item>
                        
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="22">
                       
                    <!-- </el-col>
                    <el-col :span="12"> -->
                        <el-form-item label="备注:" prop="name">
                            <el-input type="textarea" placeholder="请输入内容" v-model="form.content" maxlength="100" show-word-limit ></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <div v-if="title == '编辑'">
                 <el-table
                :data="giveTableData"
                style="width: 100%">
                    <el-table-column
                        prop="userName"
                        align="center"
                        label="操作员"
                        width="180">
                    </el-table-column>
                    <el-table-column
                        prop="createTime"
                        align="center"
                        label="操作时间"
                        >
                    </el-table-column>
                    <el-table-column
                        prop="content"
                        align="center"
                        label="内容"
                        >
                    </el-table-column>
                </el-table>
            </div>
            <div slot="footer" class="dialog-footer">
                <el-button size="mini" @click="open = false">取 消</el-button>
                <el-button size="mini" type="primary" @click="submitForm">确 定</el-button>
            </div>
        </el-dialog>
        <el-dialog title="领取列表" :visible.sync="seeVis" width="80%">
            <el-table
            border
            :data="gaveTableData"
            style="width: 100%">
                <el-table-column
                    prop="userName"
                    align="center"
                    label="领用人姓名"
                    width="180">
                </el-table-column>
                <el-table-column
                    prop="requisitionNumber"
                    align="center"
                    label="领取数量"
                    >
                </el-table-column>
                <el-table-column
                    prop="unitPrice"
                    align="center"
                    label="单价"
                    >
                </el-table-column>
                <el-table-column
                    prop="totalPrice"
                    align="center"
                    label="总价"
                    >
                </el-table-column>
                <el-table-column
                    prop="createTime"
                    align="center"
                    label="领用时间"
                    >
                </el-table-column>
                <el-table-column
                    prop="type"
                    :formatter="(row,cloumn) => row.type == row.type == 0?'到期归还':row.type == 1?'正常领用':row.type == 2?'取消领用':''"
                    align="center"
                    label="领用时间"
                    >
                </el-table-column>
            </el-table>
            <span slot="footer" class="dialog-footer">
                <el-button size="mini" type="primary" @click="seeVis = false">确 定</el-button>
            </span>
        </el-dialog>
        <el-dialog title="领取" :visible.sync="receVis" width="50%">
            <el-form label-width="140px" :rules="orderRules" ref="seeForm" :model="seeForm">
            <el-row>
            <el-col :span="12">
                <el-form-item label="订单号:" prop="orderSn">
                    <el-input disabled v-model="seeForm.orderSn"></el-input>
                </el-form-item>
                </el-col>
            <el-col :span="12">
                <el-form-item label="领取数量:" prop="requisitionNumber">
                    <el-input-number :min="1"  v-model="seeForm.requisitionNumber" @change="changeNumber"></el-input-number>
                </el-form-item>
                </el-col>
            </el-row>
            <el-row>
            <el-col :span="12">
                 <el-form-item label="领取订单号:" prop="receiveOrderSn">
                    <el-input   v-model="seeForm.receiveOrderSn"></el-input>
                </el-form-item>
                 </el-col>
            <el-col :span="12">
                <!-- <el-form-item label="入库理由:" prop="crystal">
                      <el-select v-model="form.crystal" placeholder="请选择入库原因" clearable >
                            <el-option
                            v-for="item in crystalOptions"
                            :key="item.dictLabel"
                            :label="item.dictLabel"
                            :value="item.dictLabel"
                            >
                            </el-option>
                        </el-select>
                </el-form-item> -->
                <el-form-item label="价格类型:" prop="typeId">
                    <el-select disabled v-model="seeForm.typeId" placeholder="请选择">
                        <el-option v-for="(item , index) in options" :key="index" :label="item.type" :value="item.id"></el-option>
                    </el-select>
                </el-form-item>
                </el-col>
            </el-row>
            <el-row>
            <el-col :span="12">
                <el-form-item label="边框颜色:" prop="borderColor">
                    <el-select disabled  v-model="seeForm.borderColor" placeholder="请选择">
                        <el-option label="银色" value="银色"></el-option>
                        <el-option label="黑色" value="黑色"></el-option>
                    </el-select>
                </el-form-item>
                </el-col>
            <el-col :span="12">
                <el-form-item label="线长:" prop="lineLength">
                    <el-select disabled v-model="seeForm.lineLength" placeholder="请选择线长" >
                        <el-option
                        v-for="item in lineOptions"
                        :key="item.dictLabel"
                        :label="item.dictLabel"
                        :value="item.dictLabel"
                        >
                        </el-option>
                    </el-select>
                </el-form-item>
                 </el-col>
            </el-row>
            <el-row>
            <el-col :span="12">
                <el-form-item label="背板:" prop="backboard">
                    <el-select disabled v-model="seeForm.backboard" placeholder="请选择背板" >
                        <el-option
                        v-for="item in backboardOptions"
                        :key="item.dictLabel"
                        :label="item.dictLabel"
                        :value="item.dictLabel"
                        >
                        </el-option>
                    </el-select>
                </el-form-item>
                 </el-col>
            <el-col :span="12">
                <el-form-item label="能源标识:" prop="identification">
                    <el-select disabled v-model="seeForm.identification" placeholder="请选择能源标识" >
                        <el-option
                        v-for="item in enerOptions"
                        :key="item.dictLabel"
                        :label="item.dictLabel"
                        :value="item.dictLabel"
                        >
                        </el-option>
                    </el-select>
                </el-form-item>
                 </el-col>
            </el-row>
            <el-row>
            <el-col :span="12">
                <el-form-item label="铭牌:" prop="nameplate">
                    <el-select disabled v-model="seeForm.nameplate" placeholder="请选择铭牌" >
                        <el-option
                        v-for="item in nameplateOptions"
                        :key="item.dictLabel"
                        :label="item.dictLabel"
                        :value="item.dictLabel"
                        >
                        </el-option>
                    </el-select>
                </el-form-item>
                </el-col>
            <el-col :span="12">
                <el-form-item label="包装规格:" prop="standards">
                    <el-input disabled style="width:208px"  v-model="seeForm.standards"></el-input>
                </el-form-item>
                 </el-col>
            </el-row>
               <el-form-item label="型号:" prop="model">
                    <!-- <el-input disabled v-model="seeForm.model"></el-input> -->
                    <el-select disabled v-model="seeForm.model" placeholder="请选择型号" >
                    <el-option
                    v-for="item in modelOptions"
                    :key="item.dictLabel"
                    :label="item.dictLabel"
                    :value="item.dictLabel"
                    >
                    </el-option>
                </el-select>
                </el-form-item>
            </el-form>
                <span slot="footer" class="dialog-footer">
                    <el-button size="mini" type="primary" @click="receSure">确 定</el-button>
                </span>
        </el-dialog>
  </div>
</template>

<script>
import { getList , addSure , edSure , getList1 , giveList , gaveList , receSure } from "@/api/systemSettings/index.js"; // 权限判断函数


export default {
    data () {
        return {
          rules: {
            orderSn: [
            { required: true, message: "请输入订单号", trigger: "blur" }
            ],
            requisitionNumber: [{ required: true, message: "请输入领取数量", trigger: "blur" }],
            typeId: [
            { required: true, message: "请选择类型名称", trigger: "blur" }
            ],
            crystal: [
            { required: true, message: "请选择单/多晶", trigger: "blur" }
            ],
            putTime: [
            { required: true, message: "请选择入库日期", trigger: "blur" }
            ],
            dimensions: [
            { required: true, message: "请输入尺寸", trigger: "blur" }
            ],
            wattage: [
            { required: true, message: "请输入瓦数", trigger: "blur" }
            ],
            putNumber: [
            { required: true, message: "请输入入库数量", trigger: "blur" }
            ],
            assemblyLevel: [{ required: true, message: "请输入组件级别", trigger: "blur" }],
            standards: [{ required: true, message: "请输入包装规格", trigger: "blur" }],
            lineLength: [
            { required: true, message: "请选择线长", trigger: "blur" }
            ],
             identification: [
            { required: true, message: "请选择能源标识", trigger: "blur" }
            ],
             nameplate: [
            { required: true, message: "请选择铭牌", trigger: "blur" }
            ],
            packing: [
            { required: true, message: "请输入包装方式", trigger: "blur" }
            ],
           
        },
        orderRules:{
             receiveOrderSn:[
            { required: true, message: "请输入领取订单号", trigger: "blur" }
            ],
        },
            loading:false,
            dialogVisible:false,
            seeVis:false,
            receiveVis:false,
            receVis:false,
            tableData:[],
            giveTableData:[],
            gaveTableData:[],
            title:'',
            open:false,
            queryParams:{
                orderSn:'',
                pageNum: 1,
                pageSize: 10
            },
            params:{
                pageNum: 1,
                pageSize: 10
            },
            params1:{
                startDate:'',
                endDate:new Date(),
            },
            total:0,
            seeForm:{},
            options:[],
            form:{
                packing:0,
            },
            statusOptions:[],
            advanceCount:'',
            deliverCount:'',
            paymentCount:'',
            surplusCount:'',
            totalCount:'',
            unpaidCount:'',
            sizeOptions:[],
            modelOptions:[],
            baseOptions:[],
            watOptions:[],
            lineOptions:[],
            enerOptions:[],
            backboardOptions:[],
            nameplateOptions:[],
            crystalOptions:[],
        }
    },
    created() {
        this.getDicts("sys_size").then(response => {
        this.sizeOptions = response.data;
        });
        this.getDicts("sys_model").then(response => {
        this.modelOptions = response.data;
        });
        this.getDicts("sys_base").then(response => {
        this.baseOptions = response.data;
        });
        this.getDicts("sys_wat").then(response => {
        this.watOptions = response.data;
        });
        this.getDicts("line_length").then(response => {
        this.lineOptions = response.data;
        });
        this.getDicts("sys_ener").then(response => {
        this.enerOptions = response.data;
        });
        this.getDicts("beiban").then(response => {
        this.backboardOptions = response.data;
        });
        this.getDicts("namePlate").then(response => {
        this.nameplateOptions = response.data;
        });
        this.getDicts("sys_crystal").then(response => {
        this.crystalOptions = response.data;
        });
        this.getList00()
        this.getMoney()
        this.getdatatime()
    },
    methods: {
        getdatatime(){//默认显示今天
        // this.params1.endDate= new Date();
        let myDate = new Date()
		let yy = String(myDate.getFullYear())  
		let mm = myDate.getMonth() + 1  
		let dd = String(myDate.getDate() < 10 ? '0' + myDate.getDate() : myDate.getDate())
        this.params1.endDate = yy + '-' + mm + '-' + dd

        var date = new Date()
        date.setDate(1)
        var month = parseInt(date.getMonth() + 1)
        var day = date.getDate()
        if (month < 10)  month = '0' + month
        if (day < 10)  day = '0' + day
        this.params1.startDate = date.getFullYear() + '-' + month + '-' + day
        },
        search1(){
            this.getData()
        },
        fun(val){
            return Number(val).toFixed(2);
        },
        changeNumber(currentValue, oldValue){
            if(currentValue > this.seeForm.surplusNumber){
                this.$message.warning('数量不足')
            }
        },
        add() {
            this.open = true;
            this.form = { }
            this.title = '新增'
        },
        ed(row) {
            this.form = JSON.parse(JSON.stringify(row))
            giveList(this.form.id).then(res => {
                if(res.code == 200){
                    this.giveTableData = res.rows
                }else{
                    this.giveTableData = []
                }
            })
            this.title = '编辑'
            this.open = true
        },
        search() {
            this.queryParams.pageNum = 1
            this.getList00()
        },
        see(row) {
            gaveList(row.id).then(res => {
                if(res.code == 200){
                    this.gaveTableData = res.rows
                    this.seeVis = true;
                }else{
                    this.gaveTableData = []
                }
            })

        },
        receSure() {
            this.$refs["seeForm"].validate(valid => {
            if (valid) {
                receSure(this.seeForm).then(res => {
                if(res.code == 200){
                    this.$message.success('领取成功')
                    this.getList00()
                    this.receVis = false
                }
            })
            }
            });
            
        },
        receive(row) {
            this.seeForm = JSON.parse(JSON.stringify(row))
            this.seeForm.poolId = this.seeForm.id
            this.seeForm.requisitionNumber = 1
            this.receVis = true
        },
        submitForm() {
          this.$refs["form"].validate(valid => {
            if (valid) {
            if(this.title == '新增'){
                addSure(this.form).then(res => {
                    if(res.code == 200){
                        this.open = false
                        this.getList00()
                    }
                })
            }else if(this.title == '编辑'){
                edSure(this.form).then(res => {
                    if(res.code == 200){
                        this.open = false
                        this.getList00()
                    }
                })
            }
            }
            });
        },
        getMoney() {
            getList1({pageNum:1,pageSize:10000}).then(res => {
                if(res.code == 200){
                    this.options = res.rows
                }
            })
        },
        getList00(){
            getList(this.queryParams).then(res => {
                if(res.code == 200){
                    this.tableData = res.rows
                    this.total = res.total
                }
            })
        }
    }
}
</script>

<style>

</style>